//
//  CQContactAddView.m
//  HiChat
//
//  Created by wqiong on 16/1/20.
//  Copyright © 2016年 wqiong. All rights reserved.
//

#import "CQContactAddView.h"


@interface CQContactAddView () <UITextFieldDelegate>

@end

@implementation CQContactAddView

- (void)dealloc
{
    [_label release];
    [_nameField release];
    
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubviews];
    }
    return self;
}


- (void)creatSubviews {
    
    self.label = [UILabel new];
    self.label.text = @"添加好友:";
    self.label.layer.cornerRadius = 10;
    [self addSubview:self.label];
    [_label release];
    
    self.nameField = [UITextField new];
    self.nameField.placeholder = @"请输入用户名";
    self.nameField.delegate = self;
    [self addSubview:self.nameField];
    [_nameField release];
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [self.nameAddDelegate sendNameField:self.nameField.text];
    [_nameField resignFirstResponder];
    return YES;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.label.frame = CGRectMake(0, 20, self.bounds.size.width / 4, self.bounds.size.height - 20);
    self.nameField.frame = CGRectMake(self.label.frame.origin.x + self.label.bounds.size.width, 20, self.bounds.size.width * 3 / 4, self.bounds.size.height - 20);
}

@end
